export let imgView = {
  data () {
    return {
      imgInitIndex: 0 // 图片初始渲染索引
    }
  },
  methods: {
    handleImgsClick (imgs, index) {
      // console.log(imgs)
      this.initialIndex = index
      // 根据您的图片数组的数据结构来
      let preList = imgs.map((item) => {
        return item
      })
      const params = {
        $props: {
          imgs: preList,
          initialIndex: 'initialIndex', // 响应式数据的key名
          loop: false,
          zIndex: 999
        },
        $events: {
          change: (i) => {
            // 必须更新 initialIndex
            this.initialIndex = i
          }
        }
      }
      this.$createImagePreview({ ...params }).show()
    }
  }
}
// 下拉刷新
export let PullDownRefreshAndPullUpLoad = {
  computed: {
    options () {
      return {
        'pullDownRefresh': this.pullDownRefreshObj,
        'pullUpLoad': this.pullUpLoadObj
      }
    },
    pullDownRefreshObj () {
      return this.pullDownRefresh ? {
        threshold: this.pullDownRefreshThreshold,
        // Do not need to set stop value, but you can if you want
        // stop: parseInt(this.pullDownRefreshStop),
        stop: this.pullDownRefreshStop,
        stopTime: this.stopTime,
        txt: this.pullDownRefreshTxt
      } : false
    },
    pullUpLoadObj () {
      return this.pullUpLoad ? {
        threshold: this.threshold,
        txt: this.txt
      } : false
    }
  },
  data () {
    return {
      page: 1, // 当前页数
      pullDownRefresh: true, // 是否开启下拉刷新
      pullDownRefreshTxt: '刷新成功', // 刷新成功的文案
      pullDownRefreshThreshold: 90, // 下拉刷新动作的下拉距离阈值 cubeui默认90
      pullDownRefreshStop: 40, // 回弹停留的位置
      stopTime: 600, // 刷新成功停留的文案时间，默认600ms
      pullUpLoad: true, // 是否开启上拉加载
      threshold: 90, // 上拉加载的阈值
      txt: {
        more: '下拉加载更多',
        noMore: '没有更多了(*^▽^*)哦,亲'
      }
    }
  }
}
